import Vue from 'vue'
import Router from 'vue-router'

const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)


import customerRouter from './modules/customer'
import {settingRouter} from './modules/setting'
import financeRouter from './modules/finance'
import lawcaseRouter from './modules/lawcase'
import contractRouter from './modules/contract'
import indexRouter from './modules/index'

export const constantRouterMap = [
	{
		path: '/login',
		component:() => import('@/views/login/index'),
		hidden: true
	},
	{
		path: '/404',
		component:() => import('@/views/404'),
		hidden: true
	},
	{
		path: '*',
		redirect: '/404',
		hidden: true
	}
]

export default new Router({
  // mode: 'history',
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
	customerRouter,
	settingRouter,
	financeRouter,
	lawcaseRouter,
	contractRouter,
	indexRouter
]
